package io.renren.modules.app.controller;


import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.ArtilceData;
import io.renren.modules.app.service.ArtilceDataService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 文章内容表
 *
 * @author chenjiacheng
 * @email 
 * @date 2019-02-11 19:04:20
 */
@RestController
@RequestMapping("app/artilcedata")
public class ArtilceDataController {
    @Autowired
    private ArtilceDataService artilceDataService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:artilcedata:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = artilceDataService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{content}")
    @RequiresPermissions("app:artilcedata:info")
    public R info(@PathVariable("content") String content){
			ArtilceData artilceData = artilceDataService.selectById(content);

        return R.ok().put("artilceData", artilceData);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("app:artilcedata:save")
    public R save(@RequestBody ArtilceData artilceData){
			artilceDataService.insert(artilceData);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:artilcedata:update")
    public R update(@RequestBody ArtilceData artilceData){
			artilceDataService.updateById(artilceData);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:artilcedata:delete")
    public R delete(@RequestBody String[] contents){
			artilceDataService.deleteBatchIds(Arrays.asList(contents));

        return R.ok();
    }

}
